package com.java.demo.thread;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

/**
 * @auther zhangwj
 * @date 2020/8/18 10:27 上午
 */
public class Demo4 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(5);
        FutureTask<Long> futureTask = new FutureTask<>(() -> add(100000000000L));
        executorService.submit(futureTask);
        System.out.println(futureTask.get());
    }

    public static long add(long mun) {
        long a = 0;
        for (long i = 1; i < mun; i++) {
            a = a + i;
        }
        return a;
    }
}


